﻿using Himp.Base;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;

namespace Himp.Outpatient
{
    /// <summary>
    /// 门诊处方记录
    /// 医生接诊时生成处方记录
    /// </summary>
    public class OtpRxRec : AuditedAggregateRoot<Guid>, IMultiTenant
    {
        /// <summary>
        /// 门诊就诊记录
        /// </summary>
        public Guid OtpMdtrtRecId { get; set; }

        /// <summary>
        /// 门诊就诊记录
        /// </summary>
        public OtpMdtrtRec OtpMdtrtRec { get; set; }

        /// <summary>
        /// 处方号
        /// </summary>
        public string Rxno { get; set; }

        /// <summary>
        /// 处方类别Id
        /// </summary>
        public Guid OtpRxTypeId { get; set; }

        /// <summary>
        /// 处方类别名称
        /// </summary>
        public string OtpRxTypeName { get; set; }

        /// <summary>
        /// 处方类别
        /// </summary>
        public OtpRxType OtpRxType { get; set; }

        /// <summary>
        /// 发生日期
        /// </summary>
        public DateTime BeginDate { get; set; }

        /// <summary>
        /// 开单科室
        /// </summary>
        public Guid BilgDeptId { get; set; }

        /// <summary>
        /// 开单科室名称
        /// </summary>
        public string BilgDeptName { get; set; }

        /// <summary>
        /// 开单医生编码
        /// </summary>
        public Guid BilgDrId { get; set; }

        /// <summary>
        /// 开单医师
        /// </summary>
        public string BilgDrCodg { get; set; }

        /// <summary>
        /// 开单医师姓名
        /// </summary>
        public string BilgDrName { get; set; }

        /// <summary>
        /// 审核医师
        /// </summary>
        public string? ChkDrCodg { get; set; }

        /// <summary>
        /// 审核医师
        /// </summary>
        public string? ChkDrName { get; set; }

        /// <summary>
        /// 审核时间
        /// </summary>
        public DateTime? ChkTime { get; set; }

        /// <summary>
        /// 有效期
        /// </summary>
        public DateTime? Expy { get; set; }

        /// <summary>
        /// 处方状态
        /// </summary>
        public EnumRxStats RxStats { get; set; }

        /// <summary>
        /// 医院审批标志
        /// </summary>
        public bool HospApprFlag { get; set; }

        /// <summary>
        /// 外购处方标志
        /// </summary>
        public bool RxCircFlag { get; set; }

        /// <summary>
        /// 病种编码
        /// </summary>
        public string? DiseCodg { get; set; }

        /// <summary>
        /// 处方总费用
        /// </summary>
        public decimal RxTotAmt { get; set; }


        ///// <summary>
        ///// 订单ID
        ///// </summary>
        //public Guid? OrderId { get; set; }

        //// <summary>
        ///// 退款单ID
        ///// </summary>
        //public Guid? RefundId { get; set; }

        /// <summary>
        /// 门诊处方明细
        /// </summary>
        public List<OtpRxRecDetl> OtpRxRecDetls { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Guid? TenantId { get; set; }

        public OtpRxRec()
        {

        }

        public OtpRxRec(string rxno, Guid otpMdtrtRecId, Guid otpRxTypeId
            , Guid bilgDeptId, Guid bilgDrId)
        { 
            Rxno = rxno;
            OtpMdtrtRecId = otpMdtrtRecId;
            OtpRxTypeId = otpRxTypeId;
            BilgDeptId = bilgDeptId;
            BilgDrId = bilgDrId;
            BeginDate = DateTime.Now;
        }

        public void SetChk(string? chkDrCodg, string? chkDrName)
        {
            ChkDrCodg = chkDrCodg;
            ChkDrName = chkDrName;
            RxStats = EnumRxStats.已审核;
            ChkTime = DateTime.Now;
            //OrderId = orderId;
        }
    }
}
